package com.example.Nurse_Notifier;

import android.content.Context;
import android.graphics.drawable.Drawable;

public class HistString {

    public static final int DEVICE_REMOVED = 0;
    public static final int DEVICE_STATUS_TO_IDLE = 1;
    public static final int DEVICE_STATUS_TO_SCAN = 2;
    public static final int DEVICE_STATUS_TO_ALARM = 3;
    public static final int DEVICE_ADDED = 4;
    public static final int DEVICE_BUTTON_PRESSED = 5;
    public static final int DEVICE_BUTTON_UNPRESSED = 6;
    public static final int DEVICE_DATE_IDENTIFIER = 7;

    public final String STR_FIRST_PART = "Устройство №";
    public final String STR_DEVICE_ADDED = " обнаружено";
    public final String STR_DEVICE_REMOVED = " выключено";
    public final String STR_DEVICE_TO_SCAN = " в режиме сканирования";
    public final String STR_DEVICE_TO_IDLE = " в режиме ожидания";
    public final String STR_DEVICE_TO_ALARM = " в режиме оповещения";
    public final String STR_BUTTON_PRESSED = "Кнопка нажата на устройстве №";
    public final String STR_BUTTON_UNPRESSED = "Кнопка отпущена на устройстве №";
    public final String TIME_STRING = "Время события: ";

    private int deviceId;
    private int stringType;
    private int eventId;
    private Drawable drawable;
    private String eventTime;
    private String primaryString;
    private String secondaryString;
    private Context context;

    public HistString(Context context, int eventId, int deviceId, int stringType) {
        this.context = context;
        this.eventId = eventId;
        this.deviceId = deviceId;
        eventTime = XbeeDevice.getCurTime();
        secondaryString = TIME_STRING + eventTime;
        this.stringType = stringType;
        customizeView(stringType);
    }

    public void customizeView(int stringType) {
        switch (stringType) {
            case DEVICE_ADDED: {
                drawable = context.getResources().getDrawable(R.drawable.hist_found_image);
                primaryString = STR_FIRST_PART + deviceId + STR_DEVICE_ADDED;
                break;
            }
            case DEVICE_REMOVED: {
                drawable = context.getResources().getDrawable(R.drawable.hist_off_image);
                primaryString = STR_FIRST_PART + deviceId + STR_DEVICE_REMOVED;
                break;
            }
            case DEVICE_STATUS_TO_SCAN: {
                drawable = context.getResources().getDrawable(R.drawable.hist_scan_image);
                primaryString = STR_FIRST_PART + deviceId + STR_DEVICE_TO_SCAN;
                break;
            }

            case DEVICE_STATUS_TO_IDLE: {
                drawable = context.getResources().getDrawable(R.drawable.hist_idle_image);
                primaryString = STR_FIRST_PART + deviceId + STR_DEVICE_TO_IDLE;
                break;
            }

            case DEVICE_STATUS_TO_ALARM: {
                drawable = context.getResources().getDrawable(R.drawable.hist_alarm_image);
                primaryString = STR_FIRST_PART + deviceId + STR_DEVICE_TO_ALARM;
                break;
            }

            case DEVICE_BUTTON_PRESSED: {
                drawable = context.getResources().getDrawable(R.drawable.button_red_small);
                primaryString = STR_BUTTON_PRESSED + deviceId;
                break;
            }

            case DEVICE_BUTTON_UNPRESSED: {
                drawable = context.getResources().getDrawable(R.drawable.button_green_small);
                primaryString = STR_BUTTON_UNPRESSED + deviceId;
                break;
            }

            case DEVICE_DATE_IDENTIFIER: {

            }

            default:
                break;
        }
    }

    public int getEventId() {
        return eventId;
    }

    public void setEventId(int eventId) {
        this.eventId = eventId;
    }

    public int getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(int deviceId) {
        this.deviceId = deviceId;
    }

    public String getEventTime() {
        return eventTime;
    }

    public void setEventTime(String eventTime) {
        this.eventTime = eventTime;
    }

    public int getStringType() {
        return stringType;
    }

    public void setStringType(int stringType) {
        this.stringType = stringType;
    }

    public Drawable getDrawable() {
        return drawable;
    }

    public String getPrimaryString() {
        return primaryString;
    }

    public String getSecondaryString() {
        return secondaryString;
    }
}
